"""
The MIT License (MIT)
Copyright © 2020 Walkline Wang (https://walkline.wang)

Original repo at https://github.com/micropython/micropython/tree/master/examples/bluetooth
"""

PACK = ...
UNPACK = ...

class BLETools(object):
	@staticmethod
	def advertising_generic_payload(limited_disc=False, br_edr=False, name=None, services=None, appearance=0):
		"""
		Generate a payload to be passed to gap_advertise(adv_data=...).
		"""
		...

	@staticmethod
	def __decode_field(payload, adv_type):
		"""
		__decode_field
		"""
		...

	@staticmethod
	def decode_name(payload):
		"""
		Decode advertising device name from payload
		"""
		...

	@staticmethod
	def decode_services_data(payload):
		"""
		Decode and split Service Data from payload
		
		Return: Service UUID and their Data in separated list
		"""
		...

	@staticmethod
	def decode_mac(addr):
		"""
		Decode readable mac address from advertising addr
		"""
		...

	@staticmethod
	def decode_services(payload):
		"""
		Decode Service UUIDs from payload
		"""
		...

	@staticmethod
	def decode_beacon_data(payload):
		"""
		Decode beacon payload into a sequence list
		
		Return:
		    for iBeacon: BeaconType, proximity_uuid, major, minor, tx_power
		"""
		...

	@staticmethod
	def __decode_uuid(uuid):
		"""
		__decode_uuid
		"""
		...

	@staticmethod
	def bytes_to_int(value, big_end=True, signed=False):
		"""
		bytes_to_int
		"""
		...

	@staticmethod
	def advertising_hid_payload(services=None, appearance=0):
		"""
		Generate paylaod for HID device
		"""
		...

	@staticmethod
	def advertising_resp_payload(name=None, services=None):
		"""
		Generate payload for Scan Response
		"""
		...

	@staticmethod
	def __shorten_beacon_url(url):
		"""
		Shorten the url for Eddystone-URL
		
		Reference: http://www.espruino.com/modules/ble_eddystone.js
		"""
		...

	@staticmethod
	def advertising_eddystone_payload(frame_type, **kwargs):
		"""
		According to frame_type generate payload for Eddystone.

		frame_type:
		    BLEConst.Eddystone.EDDYSTONE_URL
		    BLEConst.Eddystone.EDDYSTONE_UID
		    BLEConst.Eddystone.EDDYSTONE_EID
		"""	
		...

	@staticmethod
	def convert_tx_power_level(level_dBm=None, level_int=None):
		"""
		Convert tx power level between dBm and int

		How to determine tx power level: https://github.com/google/eddystone/tree/master/eddystone-url#tx-power-level
		
		In short:
		    0xED-0xFF=237-255=-18
		    0x12=18
		"""
		...

	@staticmethod
	def validate_intervals(min_interval, max_interval, latency, timeout):
		"""
		Verify parameters match the requirements of Apple Connection Parameters
		"""

		"""
		The connection parameter request may be rejected if it does not comply with all of these rules:
		Slave Latency ≤ 30 1
		2s ≤ connSupervisionTimeout ≤ 6s 1
		Interval Min modulo 15ms == 0
		Interval Min ≥ 15ms 1
		One of the following:
			Interval Min + 15ms ≤ Interval Max 1
			Interval Min == Interval Max == 15ms
		Interval Max * (Slave Latency + 1) ≤ 2s 1
		Interval Max * (Slave Latency + 1) * 3 < connSupervisionTimeout
		"""
		...

	@staticmethod
	def advertising_ibeacon_payload(proximity_uuid, major, minor, tx_power):
		"""
		Generate paylaod for Apple iBeacon device
		"""
		...

	@staticmethod
	def is_ibeacon_payload(payload):
		"""
		Determine if it is iBeacon payload
		"""
		...
